/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trechatserver;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author SKL
 */
public class TREChatServer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket=null;
    Socket client;
        System.out.println("Establishing Connection. Please wait...");
   try{

           serverSocket =new ServerSocket(58342);            
           System.out.println("Server Started.");
       }catch(Exception e)
       {
           System.out.println(e.getMessage());
       }

        while (true) 
        {
            try
            {
                client = serverSocket.accept();
                new listener(client).start();
            }
            catch(Exception e)
            {
                String err=e.getMessage();
                if(err == null)
                {
                   break;
                }   
                else
                {
                    System.out.println(e.getMessage());
                }
            }

        }
    }
}
